<!doctype html>
<html>
<head>
<title>layer-更懂你的web弹窗解决方案</title>
<script src="layer/laytpl.js"></script>
</head>
<body>



<script>
//假设你得到了这么一段数据
var data = {
    title: '前端圈',
    intro: '一群码js的骚年，幻想改变世界，却被世界改变。',
    list: [{name: '贤心', city: '杭州'},  {name: '谢亮', city: '北京'}, {name: '浅浅', city: '杭州'}, {name: 'Dem', city: '北京'}]
};

var tpl = document.getElementById('tpl').innerHTML; //读取模版
//方式一：异步渲染（推荐）
laytpl(tpl).render(data, function(render){
    document.getElementById('view').innerHTML = render;
});

//方式二：同步渲染：
var render = laytpl(tpl).render(data);
document.getElementById('view').innerHTML = render;
</script>

<h3>{{ d.title }} {{ d.title ? ' - 群/176047036' : '' }}</h3>
<p class="intro">{{ d.intro }}</p>
<ul>
{{# for(var i = 0, len = d.list.length; i < len; i++){ }}
    <li>
        <span>{{ d.list[i].name }}</span>
        <span>所在城市：{{ d.list[i].city }}</span>
    </li>
{{# } }}
</ul>




</body>
</html>